package dS.ProjectGPS.LeicaOWI;

import javax.microedition.lcdui.*;

public class FormOwiRCM extends Form implements FormOwi {

  OWIAgent owiAgent = null;

  StringItem description = new StringItem("", "Reset fo default settings",
                                          StringItem.PLAIN);
  ChoiceGroup mode = new ChoiceGroup("", ChoiceGroup.EXCLUSIVE);

  public FormOwiRCM(OWIAgent o) {
    super("Reset Control Mode");

    owiAgent = o;

    try {
      ndsInit();
    }
    catch (Exception ex) {
    }
  }

  public void ndsInit() throws Exception {
    append(description);
    append(mode);
    mode.append("Set Primary Port to Terminal Port", null);
    mode.append("Primary Port remains the same port", null);
    description.setPreferredSize(171, 13);
  }

  public void update() {
    // N/A
  }

  public void save() {

    String msgId = "RCM";

    // Setup SET parameters
    String[] outputs = {msgId,
                       "" + mode.getSelectedIndex(),
    };

    //Send message and update form if successful
    int ackCode = (owiAgent.set(msgId, OWI.setMessage(outputs)));
    Controller.showACKAlert(this,this,ackCode);

  }
}
